#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QLabel *label = new QLabel(this);
    label->setText("to be changed");

    SubWindow *subwindow = new SubWindow(this);
    connect(subwindow, SIGNAL(sendText(QString)), this, SLOT(receiveMsg(QString)));
    subwindow->show(); // use open or exec both ok

}

void MainWindow::receiveMsg(QString str)
{
    // receive msg in the slot
    label->setText(str);
}


MainWindow::~MainWindow()
{
    delete ui;
}

